
class SerialNumberGen:
    def __init__(self, start=0, step=1):
        self.SerialNumber = start
        self.step = step
        self.ValidNumberList = []

    def Gen(self):
        if self.ValidNumberList:
            # get number from valid number list
            ret = self.validNumberList.pop(0)
        else:
            # generate a new serial number
            ret = self.SerialNumber
            self.SerialNumber += self.step
        return ret

    def ValidNumberListAdd(self, numList):
        self.ValidNumberList.append(numList)